import { InitData } from '@/components/common/typing/table'
import { commonStore } from '@/store/index'
import router from '@/router'

interface PathData {
  path: string
  params?: InitData
  query?: InitData
}
/**
 * type?:string 用什么方式 push、replace、go
 * isKeepAlive?:boolean 是否用KeepAlive
 */
interface Config {
  type?: string
  isKeepAlive?: boolean
}
export const routerTo = (pathData: PathData | string, config?: Config) => {
  // const router = useRouter()
  const store = commonStore()
  store.setKeepAlive(!!config?.isKeepAlive)
  setTimeout(() => {
    router[config?.type || 'push'](pathData)
  }, 20)
}
